{extend name="../../base/view/layout" /}
{block name="my_body"}
<div class="maincontent">
    <div class="maincontentinner">

        <table id="dyntable" class="table table-bordered responsive">
            <thead>
            <tr>
                <th class="center"><input type="checkbox" class="checkall" /></th>
                <th class="center">ID</th>
                <th class="center">分类名称</th>
                <th class="center">菜单显示</th>
                <th class="center">图标</th>
                <th class="center">操作</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach($data as $v):?>
            <tr >
                <td class="aligncenter"><span class="center">
                            <input type="checkbox" />
                          </span></td>
                <td class="center "><?php echo $v['id'];?></td>
                <td class="center"><?php echo str_repeat('-',$v['level']),$v['name'];?></td>
                <td class="center"><?php $v['is_show']==1?$show='iconfa-ok':$show='iconfa-remove';?><i class="<?php echo $show;?>"></i></td>
                <td class="center"><?php showImage($v['ico'],'20','20');?></td>
                <td class="center">
                    <a href="<?php echo url('edit',['id'=>$v['id']]);?>">修改</a>
                    | <a thisid="<?php echo $v['id'];?>" href="javascript:;" onclick="del(this)">删除</a>
                </td>
            </tr>
            <?php endforeach;?>

            </tbody>
        </table>

        <br /><br />


    </div><!--maincontentinner-->
</div><!--maincontent-->
{/block}

{block name="my_js"}

<script>
    function del(t)
    {
        var id = jQuery(t).attr('thisid');
        var url = "<?php echo url('del');?>";
        jQuery.ajax({
            type: 'POST',
            url: url,
            data:"id="+id,
            dataType: 'JSON',
            success: function(res){
                if(res.code == 0)
                {
                    jQuery(t).parent().parent().remove();
                }
                else
                {
                    var html = '<div class="widgetbox box-danger"><h4 class="widgettitle">错误提示 <a class="close">×</a> <a class="minimize">–</a></h4><div class="widgetcontent">'+res.msg+'</div></div>';
                    var h = jQuery(html);
                    jQuery(".maincontentinner").prepend(h);
                    window.setTimeout(function(){
                        h.remove();
                    },1000);
                }
            }
        })
    }
</script>

{/block}
